<!--
 * @Author: 码上talk|RC
 * @Date: 2021-09-08 16:08:37
 * @LastEditTime: 2022-02-17 08:25:11
 * @LastEditors: 码上talk|RC
 * @Description: 
 * @FilePath: /ma-distributor/App.vue
 * @微信:  13680065830
 * @邮箱:  3189482282@qq.com
 * @oops: Just do what I think it is right
-->
<script>
  import {
    mapState,
    mapActions
  } from 'vuex';
  import {
    localStorage
  } from './utils/localStorage'
  import {
    get
  } from 'lodash'
  export default {
    data() {
      return {}
    },
    computed: {
      ...mapState('user', ['info']),
    },
    methods: {
      ...mapActions(['initApp']),
    },
    watch: {
      info: {
        handler: function (e) {
          e._raw && !this.black_Get(e, '_raw.isCertificate', 0) && Promise.resolve().then(() => {
            uni.showModal({
              showCancel: false,
              confirmColor: "#DB187C",
              confirmText: '前往认证',
              title: '提示',
              content: '您还没有完成实名认证，请前往认证!',
              success: () => {
                uni.reLaunch({
                  url: '/subpackage/member/pages/certificate/index'
                });
              },
              fail(res){
                console.log(res)
              }
            })
          })
        },
        deep: true
      }
    },
    onLaunch: function (options) {
      const {
        type,
        token
      } = get(options.referrerInfo, 'extraData', {});
      if (type) {
        const t2k = {
          1: 'api-member',
          2: 'api-distributor'
        }
        localStorage.setAppKey(t2k[type]);
        localStorage.setToken(token);
      }
      this.initApp();
    },
    onShow: function (options) {
      this.scanNavManager.handleScanCode(options)
      this.$forceUpdate();
    },
    onHide: function () {}
  };
</script>

<style lang="less">
  @import "./common/less/base";
  @import "./common/less/iconfont";
  @import "./common/less/border-1px";
</style>